<template>
  <div class="top-mid">
    <div class="item">
      <span class="name">共发现隐患
        <strong>{{all}} </strong>
        <em>起</em>
      </span>
    </div>
    <div class="item">
      <span class="name">已处理
        <strong style="color: #44ff86">{{processed}}</strong>
        <em>起</em>
      </span>
    </div>
    <div class="item">
      <span class="name">未处理
        <strong>{{unprocess}}</strong>
        <em>起</em>
      </span>
    </div>
  </div>
</template>
<script>
  import Data from '../../data/fantasy/castle/top'

  Data()
  export default {
    name: 'topMid',
    data () {
      return {
        all: 0,
        unprocess: 0,
        processed: 0
      }
    },
    mounted () {
      this.dealError()
      this.refresh()
    },
    methods: {
      dealError () {
        this.postRequest('Analysis/errorCount', {
          devType: '0'
        }).then((res) => {
          this.unprocess = 0
          this.processed = 0
          this.all = 0
          console.log('上部信息刷新')
          res.data.data.forEach((item) => {
            this.all += item.total
            this.unprocess += item.unprocess
            this.processed += item.processed
          })
        })
      },
      refresh () {
        setInterval(this.dealError, 200000)
      }
    }
  }
</script>
<style>
  .top-mid {
    position: absolute;
    left: 50%;
    top: 30px;
    width: 1650px;
    display: flex;
    justify-content: space-around;
    box-sizing: border-box;
    padding: 24px 20px 0;
    background: url(../../assets/images/common/top-center-bg.png) no-repeat top center;
    background-size: 100% 100%;
    transform: translate(-50%, 0);
    margin-left: -20px;
  }

  .item {
    max-width: 33.33%;
    overflow: hidden;
    white-space: nowrap;
  }

  .name {
    font-size: 40px;
    color: #b4c7f9;
  }

  .name strong {
    font-size: 50px;
    color: #ff8244;
    font-weight: normal;
    margin: 0 10px;
  }

  .huanbi {
    font-size: 30px;
    color: #b4c7f9;
  }

  .huanbi strong {
    font-size: 40px;
    margin: 0 10px 0 36px;
    position: relative;
    display: inline-block;
  }

  .huanbi em {
    font-size: 30px;
  }

  .huanbi strong[data-state]:after {
    content: "";
    display: inline-block;
    position: absolute;
    width: 25px;
    height: 26px;
    top: 14px;
    left: -30px;
  }

  .huanbi strong[data-state="up"] {
    color: #ff4444;
  }

  .huanbi strong[data-state="level"] {
    color: #b4c7f9;
  }

  .huanbi strong[data-state="down"] {
    color: #44ff86;
  }

  .huanbi strong[data-state="up"]:after {
    background: url(../../assets/images/common/huanbi-up.png) no-repeat;
  }

  .huanbi strong[data-state="down"]:after {
    background: url(../../assets/images/common/huanbi-down.png) no-repeat;
  }

</style>
